package cn.highedu.spring.bean13;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class ExampleBean {
    @Autowired
    @Qualifier("foo3") // 指定bean的名称
    private Foo foo;

    private Foo foo1;

    @Autowired // 先按照类型匹配，再按照名称匹配
    private Foo foo2;

    @Autowired // 先按照类型匹配，再按照名称匹配
    public void setFoo(@Qualifier("foo1") Foo foo) {
        this.foo1 = foo;
    }

    @Override
    public String toString() {
        return "ExampleBean{" +
                "foo=" + foo +
                ", foo1=" + foo1 +
                ", foo2=" + foo2 +
                '}';
    }
}
